﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using EHTSaleManager.Code.Entity;
using EHTSaleManager.Code.DAL;
using System.Data.SqlClient;
using System.Data;

namespace EHTSaleManager.Code.BLL
{
    public class ServiceLevelsProvider
    {
        public static void IUServiceLevels(ServiceLevels theServiceLevels, bool IsAdd)
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_IUServiceLevels";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@SeviceLevelID", theServiceLevels.SeviceLevelID));
            command.Parameters.Add(new SqlParameter("@Description", theServiceLevels.Description));
            command.Parameters.Add(new SqlParameter("@ServiceCost", theServiceLevels.ServiceCost));            
            command.Parameters.Add(new SqlParameter("@IsAdd", IsAdd));

            DataProvider.ExecuteNoneQuery(command);
        }
        //public static void DeleteNews(Int32 NewsID)
        //{
        //    SqlCommand command = new SqlCommand();
        //    command.CommandText = "proc_DeleteNewsByNewsID";
        //    command.CommandType = CommandType.StoredProcedure;
        //    command.Parameters.Add(new SqlParameter("@NewsID", NewsID));

        //    DataProvider.ExecuteNoneQuery(command);
        //}
        public static DataSet GetServiceLevels()
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_GetServiceLevels";
            command.CommandType = CommandType.StoredProcedure;

            return DataProvider.ExecuteDataSet(command);
        }

        public static ServiceLevels GetServiceLevelByID(int SeviceLevelID)
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_GetServiceLevelByID";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@SeviceLevelID", SeviceLevelID));

            DataSet ds = DataProvider.ExecuteDataSet(command);
            ServiceLevels theService = null;

            if (ds.Tables[0].Rows.Count > 0)
            {
                theService = new ServiceLevels();
                theService.SeviceLevelID = Int32.Parse(ds.Tables[0].Rows[0]["SeviceLevelID"].ToString());
                theService.Description = ds.Tables[0].Rows[0]["Description"].ToString();
                theService.ServiceCost = float.Parse(ds.Tables[0].Rows[0]["ServiceCost"].ToString());                
            }
            return theService;
           
        }
    }
}